package com.gimi.cloud.jimi.dao.dao.order;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.gimi.cloud.jimi.dao.dao.sys.BaseDao;
import com.gimi.cloud.jimi.dao.myMapper.MyMapper;
import com.gimi.cloud.jimi.dto.order.OrderDTO;
import com.gimi.cloud.jimi.entity.order.OrderEntity;

import java.util.List;
import java.util.Map;

/**
 * 订单dao
 * @author chendi
 * @date 2018年1月10日
 */
@Mapper
public interface OrderDao extends MyMapper<OrderEntity>,BaseDao<OrderEntity,OrderDTO>{

	@Select("SELECT status FROM sh_order WHERE o_id = #{oId} LIMIT 1")
	String getOrserStatus(@Param(value = "oId") Integer oId);

	@Select("SELECT o.o_id,o.order_code,o.`status`,g.prod_brand_name,prod_name,o.add_time,g.sku_id FROM sh_order o LEFT JOIN sh_order_goods g ON o.o_id = g.o_id WHERE o.user_id = #{userId};")
	List<Map> getListByUserId(@Param(value = "userId") Integer userId);
	
	
	@Select("SELECT o.o_id,o.order_code,o.`status`,oc.periods,o.add_time,oc.rent,oc.premium,og.`prod_name`,og.`prod_brand_name`,og.sku_id,og.price,\r\n" + 
			"oe.name,oe.`mobile`,oe.`address`\r\n" + 
			"FROM sh_order o \r\n" + 
			"INNER JOIN sh_order_cost oc \r\n" + 
			"INNER JOIN sh_order_goods og \r\n" + 
			"INNER JOIN sh_order_express oe\r\n" + 
			"WHERE o.o_id = oc.o_id AND o.o_id = og.o_id AND o.o_id = oe.`o_id` AND o.`o_id` = #{oId} LIMIT 1")
	Map<String,Object> getorderDetail(@Param(value = "oId") Integer oId);
}


